#ifndef _AV_STREAM_H_
#define _AV_STREAM_H_

#include <stdio.h>
#include <Windows.h>

#ifdef AVSTREAM_EXPORTS
	#define AVSTREAM_API __declspec(dllexport)
#else
	#define AVSTREAM_API __declspec(dllimport)
	#pragma comment(lib, "AVStream.lib")
#endif

typedef void* HAVSTREAM;

typedef enum _STREAM_SEEK_POS
{
	SEEK_STREAM_BEGIN = SEEK_SET,
	SEEK_STREAM_CURRENT = SEEK_CUR,
	SEEK_STREAM_END	= SEEK_END

}STREAM_SEEK_POS;

typedef struct _FP_AVSTREAM
{
	void* pReserve1;
	void* pReserve2;
	FILE* fp;
	TCHAR szReserve3;
}FP_AVSTREAM;

typedef struct _STREAM_FILE_INFO
{
	LPTSTR lpszFilePath;
	int nFilePathBufSize;

	time_t createTime;
	time_t modifyTime;
	long fileSize;
}STREAM_FILE_INFO;

#ifdef __cplusplus
extern "C" {
#endif

AVSTREAM_API HAVSTREAM CreateFPAVStream(FP_AVSTREAM* pFPInfo);
AVSTREAM_API HAVSTREAM CreateNormalAVStream(LPCTSTR lpszFileName, HAVSTREAM hStreamReuse);
AVSTREAM_API HAVSTREAM CreateMFSAVStream(LPCTSTR lpszFileName, unsigned long lOffset, unsigned long lSize, HAVSTREAM hStreamReuse);
AVSTREAM_API HAVSTREAM CreateWrapStream(LPCTSTR lpszFileName, void* pHeader, int nHeaderSize, void* pTail, int nTailSize, HAVSTREAM hStreamReuse);

AVSTREAM_API BOOL OpenAVStream(HAVSTREAM hStream);
AVSTREAM_API BOOL GetAVStreamFileInfo(HAVSTREAM hStream, STREAM_FILE_INFO* pFileInfo);
AVSTREAM_API size_t ReadAVStream(HAVSTREAM hStream, void* pBuffer, size_t size, size_t count);
AVSTREAM_API BOOL SeekAVStream(HAVSTREAM hStream, long loffset, STREAM_SEEK_POS PosFrom);
AVSTREAM_API unsigned long TellAVStream(HAVSTREAM hStream);
AVSTREAM_API void CloseAVStream(HAVSTREAM hStream);

AVSTREAM_API void DestroyAVStream(HAVSTREAM hStream);

#ifdef __cplusplus
}
#endif

#endif